﻿layui.use('layer', function () {
    var $ = layui.$;
    var layer = layui.layer;
    var util = layui.util;
    var form = layui.form;
    var table = layui.table;

    ///添加
    var list = {
        productionRequisitionId:'',
        requisitionNumber: '',
        requisitionName: '',
        requisitionDate: '',
        requisitionPerson: '',
        workOrderName: '',
        workOrderOrder: '',
        taskName: '',
        taskOrder: '',
        processRoute: '',
        processName: '',
        remark: '',
        rawMaterialList: []
    };
    $(function () {
        show();
    })

    function show() {
        $.ajax({
            url: "/productionPicking/productionPickingModel",
            type: "get",
            data: {
                productionRequisitionId: localStorage.getItem("productionRequisitionId"),
                token: localStorage.getItem("token")
            },
            success: function (data) {
                data = JSON.parse(data);
                $(data.data).each(function () {
                    $('#requisitionNumber').val(this.requisitionNumber)
                    $('#requisitionName').val(this.requisitionName)
                    $('#requisitionDate').val(this.requisitionDate.substring(0,10))
                    $('#requisitionPerson').val(this.requisitionPerson)
                    $('#workOrderName').val(this.workOrderName)
                    $('#workOrderOrder').val(this.workOrderOrder)
                    $('#taskName').val(this.taskName)
                    $('#taskOrder').val(this.taskOrder)
                    $('#processRoute').val(this.processRoute)
                    $('#processName').val(this.processName)
                    $('#remark').val(this.remark)
                    list.productionRequisitionId = this.productionRequisitionId
                    list.requisitionNumber = this.requisitionNumber
                    list.requisitionName = this.requisitionName
                    list.requisitionDate = this.requisitionDate
                    list.requisitionPerson = this.requisitionPerson
                    list.workOrderName = this.workOrderName
                    list.workOrderOrder = this.workOrderOrder
                    list.taskName = this.taskName
                    list.taskOrder = this.taskOrder
                    list.processRoute = this.processRoute
                    list.processName = this.processName
                    list.remark = this.remark
                    form.render('select');
                })
                var table = layui.table;
                table.render({
                    elem: '#productionPickingtable',  // 表格元素的选择器
                    page: {
                        limit: 5,
                        limits: [5, 8, 10]
                    },
                    toolbar: '#toolbarDemo',
                    defaultToolbar: ['exports'],
                    cols: [[
                        { type: 'checkbox', fixed: 'left', title: '复选框' },
                        { field: 'rawMaterialNumbering', title: '原料编号' },
                        { field: 'rawMaterialName', title: '原料名称' },
                        { field: 'rawMaterialClassify', title: '原料分类' },
                        { field: 'rawMaterialSize', title: '规格型号' },
                        { field: 'rawMaterialSpecModel', title: '尺寸' },
                        { field: 'rawMaterialinventory', title: '当前库存数量' },
                        { field: 'quantityReceived', title: '领用数量', edit: 'text' },
                        { field: 'rawMateriallocation', title: '仓库' },
                    ]],
                    // 初始时可以先不加载数据，等待 ajax 请求成功后再更新
                    data: data.data.rawMaterialList
                });
            },
            error: function () {
                console.log("请求失败");
            }
        });

        
        
        
    }
});
